<template>
	<view class="container">
		<view class="item" v-for="(item, index) in deliveryData" @key="index">
			<view class="inner">
				<view class="item-status">
					<text v-if="item.status==1" class="status-text blue-status">待发货</text>
					<text v-else-if="item.status==2" class="status-text green-status">发货中</text>
					<text v-else-if="item.status==3" class="status-text red-status">已完成</text>
				</view>
				<view class="item-words">
					<view class="item-title">达人名称 </view>
					<view class="item-text">{{item.celebrity_name}}</view>
				</view>
				<view class="item-words">
					<view class="item-title">平台单号</view>
					<view class="item-text">{{item.platform_code}}</view>
				</view>
				<view class="item-words">
					<view class="item-title">发货单号</view>
					<view class="item-text">{{item.delivery_code}}</view>
				</view>

				<view class="item-address">
					<view class="item-title">收货信息</view>
					<view class="item-address-text">
						<view class="item-text">{{item.receiver_name}} {{item.receiver_mobile}}</view>
						<view class="item-text">{{item.receiver_province}} {{item.receiver_city}} {{item.receiver_district}} {{item.receiver_address}}</view>
					</view>
				</view>
				<view class="item-words">
					<view class="item-title">物流公司</view>
					<view class="item-text">{{item.express_name}}</view>
				</view>
				<view class="item-words">
					<view class="item-title">物流单号</view>
					<view class="item-text">{{item.express_no}}</view>
				</view>
				<view class="item-words">
					<view class="item-title">发货时间</view>
					<view class="item-text">{{item.deliver_time}}</view>
				</view>
				<view class="product-list">
					<view class="product-list-item"v-for="(productItem, index) in item.item_list">
						<view class="item-left">
							<view class="product-title">{{productItem.item_name}}</view>
							<view class="item-title-mini">{{productItem.sku_name}}</view>
						</view>
						<view class="item-right">
							<view class="item-title-mini">￥{{productItem.price}}</view>
							<view class="item-title-mini">x{{productItem.quantity}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		Reserve
	} from '@/models/reserve.js'
	const reserveModel = new Reserve()
	export default {
		data() {
			return {
				deliveryData: []
			}
		},
		methods: {
			_loadData(id) {
				reserveModel.getReserveDelivery(id, (res) => {
					this.deliveryData = res
				})
			}
		},
		onLoad(options) {
			this._loadData(options.id)
		}
	}
</script>

<style>
	.item {
		background-color: #fff;
		width: 80%;
		margin: 30rpx auto;
		border-radius: 20rpx;
		padding: 30rpx;
	}

	.inner {
		line-height: 40rpx;
	}

	.item-words {
		display: flex;
		flex-direction: row;
		align-items: center;
		flex-wrap: wrap;
	}

	.item-title {
		color: #777;
		margin-right: 30rpx;
		font-size: 24rpx;
		display: flex;
		flex-direction: row;
	}
	.item-address{
		display: flex;
		flex-direction: row;
	}
	.item-address-text{
		display: flex;
		flex-direction: column;
		width: 530rpx;
	}

	.product-list {
		margin-top: 20rpx;
		padding-top: 20rpx;
		border-top: 1rpx solid #e9e9e9;
	}
	.product-list-item{
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}

	.item-left {
		width: 90%;
		line-height: 40rpx;
		display: flex;
		flex-direction: column;
	}

	.item-title-mini {
		font-size: 24rpx;
		color: #666;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}

	.item-right {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-end;
		line-height: 30rpx;
	}

	.status-text {
		margin-right: 20rpx;
	}
	
	.green-status {
		color: #6EC2AE;
	}
	
	.blue-status {
		color: #007aff;
	}
	
	.red-status {
		color: #dd524d;
	}
	
	.gray-status {
		color: #999;
	}
	.status-button{
		width: 120rpx;
		height: 50rpx;
		line-height: 50rpx;
		text-align: center;
		background-color: #dd524d;
		color: #fff;
		margin-top: 20rpx;
	}
</style>